﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.WorkTaskGrade.BLL;
using SmartWeb.BLL;

public partial class TaskNew_WorkTask : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Bind();

    }
    public void Bind()
    {
        BindYearList();
        for (int i = 1; i <= 12; i++)
        {
            this.DptMonth.Items.Add(new ListItem(i.ToString() + "月", i.ToString()));
        }

        this.DptYear.SelectedValue = DateTime.Now.Year.ToString();


        for (int i = 0; i < 20; i++)
        {
            this.DptOrderID.Items.Add(new ListItem(i.ToString(), i.ToString()));
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        lblpromt.Text = "";
        Yipusoft.WorkTaskGrade.Model.WorkTaskGradeInfo info = new Yipusoft.WorkTaskGrade.Model.WorkTaskGradeInfo();
        info.Id = Guid.NewGuid();
        //info.CompleteCircs =UserFun.TextToHtml(txtCompleteCircs.Text);
        info.CreateUserID = Yipusoft.Account.BLL.User.GetUser(User.Identity.Name).UserID;
        info.DepartmentID = Yipusoft.Account.BLL.User.GetUser(User.Identity.Name).DepartmentID;
        info.LastModifyDate = DateTime.Now;
        info.Marking = decimal.Parse(txtMarking.Text.Trim());
        info.ReMark = "";
        info.TaskDate = Convert.ToDateTime(Convert.ToDateTime(DptYear.SelectedValue + "-" + DptMonth.SelectedValue + "-1"));
        info.WorkTask = UserFun.TextToHtml(txtWorkTask.Text);
        info.OrderID = int.Parse(this.DptOrderID.SelectedValue);
        info.Score = -1;
        info.SelfScore = -1;
        info.ApproveScore = -1;
        info.IsYear = CBXIsYear.Checked ? 1 : 0;
        if (Guid.Empty != new Yipusoft.WorkTaskGrade.BLL.WorkTaskGrade().Insert(info))
        {
            Response.Redirect("WorkTaskList.aspx");
        }
        else
        {
            lblpromt.Text = "操作失败";
        }


    }
    protected void CBXIsYear_CheckedChanged(object sender, EventArgs e)
    {
        if (CBXIsYear.Checked)
        {
            DptMonth.Visible = false;
        }
        else
        {
            DptMonth.Visible = true;
        }
    }

    private void BindYearList()
    {
        for (int i = 2008; i <= 2050; i++)
        {
            ListItem li = new ListItem();
            li.Text = i.ToString() + "年";
            li.Value = i.ToString();
            DptYear.Items.Add(li);
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("WorkTaskList.aspx");
    }
}
